package top.xiesen.collection;

import java.util.HashMap;
import java.util.HashSet;

/**
 * 自定义HashSet
 * 
 * @author Allen
 *
 */
public class MyHashSet {
	HashMap map;
	private static final Object PRESENT = new Object();
	public MyHashSet() {
		map = new HashMap();
	}

	public int size(){
		return map.size();
	}
	public void add(Object o) {
		map.put(o, PRESENT); // Set是不可重复的
	}

	public boolean remove(Object o) {
		return map.remove(o) == PRESENT;
	}

	public static void main(String[] args) {
		MyHashSet s = new MyHashSet();
		s.add("aaaaaa");
		s.add(new String("aaaaaa"));
		System.out.println(s.size());
		
	}
}
